﻿/********************************************************************************
 * CoTime. All rights reserved.
 * Author: 刘冰
 * Email : ice6@live.cn
 * Description:
 *     针对UI的一些扩展方法
 *     作用是为了让程序看起来更有表达力(ToDo:重构)
*********************************************************************************/
using System;
using System.IO;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows;

namespace CoTime
{
    public static class UIHelper
    {
        public static Image GetIcon(String name)
        {
            Image image = new Image();
            image.Source = new BitmapImage(new Uri(Path.Combine(Config.AppPath, String.Format("Images/{0}.png", name))));
            image.Stretch = Stretch.None;
            image.Width = image.Height = name.EndsWith("te") ? 8 : 30;
            if (image.Width == 8)
            {
                image.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                if (name.Equals("inte"))
                {
                    image.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                }
                else if (name.Equals("exte"))
                {
                    image.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                }
            }
            image.Tag = name;
            return image;
        }
    }
}
